package com.project.restaurant.user.dto;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.project.restaurant.pojo.User;
import com.project.restaurant.user.enums.Sex;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class UpdateUserInfoParam {
    @ApiModelProperty(value = "更新的用户名;不传代表不更新")
    private String userName;
    @ApiModelProperty(value = "更新的性别;不传代表不更新")
    private Sex sex;
    @ApiModelProperty(value = "更新的个性签名;不传代表不更新")
    private String individualitySignature;

    public boolean updateUserInfo(User user){
        boolean update = false;
        if(StrUtil.isNotEmpty(userName)){
            user.setUserName(userName);
            update = true;
        }
        if(sex != null){
            user.setSex(sex.isSex());
            update = true;
        }
        if(StrUtil.isNotEmpty(individualitySignature)){
            user.setIndividualitySignature(individualitySignature);
            update = true;
        }
        return update;
    }
}
